package com.geofeature;

import android.content.Intent;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnLongClickListener;
import android.view.View.OnTouchListener;
import android.widget.Toast;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import com.google.android.maps.OverlayItem;

public class GeoMap extends MapActivity{
	private MapView mapView;
	private MapController mc;
	private GeoPoint p;
	
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);		
   		setContentView(R.layout.map);
   	    
   		
   		
   		//set the mapview
		mapView = (MapView) findViewById(R.id.mapview);
		mc = mapView.getController();
		
		p = new GeoPoint((int) (50.422697 * 1E6), (int) (30.505257 * 1E6));	
		mc.animateTo(p);
		mc.setZoom(18);
		
		
		mapView.setOnTouchListener(new OnTouchListener() {
			private long startTime = 0l;
			private long minTime = 500l;
			@Override
			public boolean onTouch(View v, MotionEvent event) {
				if(event.getAction() == MotionEvent.ACTION_DOWN){
					startTime = System.currentTimeMillis();
				}else if(event.getAction() == MotionEvent.ACTION_UP){
					if(Math.abs( startTime - System.currentTimeMillis()) > minTime){
						startTime = 0l;
						Intent intent = new Intent(GeoMap.this, TaskActivity.class);
		        		startActivity(intent);
					}
				}
				return false;
			}
		}); 
	}

	@Override
	protected boolean isRouteDisplayed() {
		// TODO Auto-generated method stub
		return false;
	}

	
/*	@Override
	public boolean onTouch(View map, MotionEvent event) {
		// TODO Auto-generated method stub
		//p = mapView.getProjection().fromPixels(event.getX(), event.getY());
		//fromPixels(event.getX(), event.getY());	
		
        //Intent intent = new Intent(GeoMap.this, TaskActivity.class);
        //startActivity(intent);
		
		return false;
	}*/

	
}
